<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set scope="request" var="title" value="图书管理"></c:set>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>${ title }</title>
    <base href="${ pageContext.servletContext.contextPath }/">
    <link rel="icon" href="statics/img/favicon.svg" sizes="any" type="image/svg+xml">
    <link rel="stylesheet" href="statics/css/base.css">
    <link rel="stylesheet" href="statics/css/manager.css">
</head>
<body>
	<%@include file="/pages/common/header.jsp" %>
    <!-- 主体 -->
    <main>
    	<section class="table-header flex">
			<p class="flex-1 flex-center color-danger">${ message }</p>
			<ul class="table-header">
				<li><a href="manager/book/add">添加图书</a></li>
				<li><a href="order">我的订单</a></li>
				<li><a href="manager/user">用户管理</a></li>
			</ul>
		</section>
		<section class="table-container">
    		<table>
	        	<thead>
	        		<tr>
		        		<td>ID</td>
		        		<td>图片</td>
		        		<td>书名</td>
		        		<td>作者</td>
		        		<td>价格</td>
		        		<td>销量</td>
		        		<td>库存</td>
		        		<td>操作</td>
		        	</tr>
	        	</thead>
	        	<tbody>
		        	<c:forEach items="${ bookList }" var="book">
		        	<tr>
		        		<th>${ book.id }</th>
		        		<td><img src="${ book.imgPath.indexOf('/upload') == 0 ? pageContext.request.contextPath : '' }${ book.imgPath }"></td>
		        		<td class="text-left">${ book.name }</td>
		        		<td>${ book.author }</td>
		        		<td>${ book.price }</td>
		        		<td>${ book.sales }</td>
		        		<td>${ book.stock }</td>
		        		<td>
		        			<a href="manager/book/update?id=${ book.id }" class="btn-link">修改</a>
		        			<a href="manager/book/delete?id=${ book.id }" class="btn-link">删除</a>
		        		</td>
		        	</tr>
		        	</c:forEach>
	        	</tbody>
	        </table>
    	</section>
        <%@include file="/pages/common/pagination.jsp" %>
    </main>
    <%@include file="/pages/common/footer.jsp" %>
</body>
</html>